using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using Afrs.Draco.Prms.Client.Proxy;
using Afrs.Prms.DataObject;

namespace 
{
  /// <summary>
  /// Boxes Test Class
  /// </summary>
  [TestClass]
  public class TestBoxes
  {
    #region Class Variables
    private CdoPrms<DOBoxes>		m_Boxes;
    private CdoPrmsList<DOBoxes>	m_AllBoxes;
    #endregion

    #region Class Constructors & Destructors
    /// <summary>
    /// Constructs the test
    /// </summary>
    public TestBoxes()
    {
      // Create the data objects
      this.m_Boxes	= new CdoPrms<DOBoxes>();
      this.m_AllBoxes	= new CdoPrmsList<DOBoxes>();
    }
    #endregion

    #region Class Methods
    /// <summary>
    /// Retrieves all Boxes data objects
    /// </summary>
    [TestMethod]
    public void BoxesRetrieveAll()
    {
      // Set up the data object for list retrieval
      this.m_AllBoxes.DataObject = new DOBoxes();
      this.m_AllBoxes.ListAction = AfrsDOListAction.Retrieve;

      // Perform the action and determine the success
      if (!this.m_AllBoxes.PerformAction())
      {
        // Assert the errors
        if (this.m_AllBoxes.Errors.Count > 0) { Assert.Fail(this.m_AllBoxes.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }

    /// <summary>
    /// Create a new Boxes
    /// </summary>
    [TestMethod]
    public void BoxesCreate()
    {
      // Set up the data object for creation
      this.m_Boxes.DataObject.BoxStatus = "Test BoxStatus";
      this.m_Boxes.DataObject.BoxLocation = "Test BoxLocation";
      this.m_Boxes.DataObject.BoxWarehouse = "Test BoxWarehouse";
      this.m_Boxes.DataObject.LastTransactionUserId = 12.3F;
      this.m_Boxes.DataObject.LastTransactionDate = DateTime.Now;
      this.m_Boxes.DataObject.Action = AfrsDataObjectAction.Create;

      // Perform the action and determine the success
      if (!this.m_Boxes.PerformAction())
      {
        // Assert the errors
        if (this.m_Boxes.Errors.Count > 0) { Assert.Fail(this.m_Boxes.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }

    /// <summary>
    /// Retrieves a specific Boxes
    /// </summary>
    [TestMethod]
    public void BoxesRetrieve()
    {
      // Determine whether the data object needs to be specified
      if (this.m_Boxes.DataObject.Id == 0)
      {
        // Specify the data object to retrieve
        this.m_Boxes.DataObject.BoxNo = "Test BoxNo";
      }

      // Set up the data object action for retrieval
      this.m_Boxes.DataObject.Action = AfrsDataObjectAction.Retrieve;

      // Perform the action and determine the success
      if (!this.m_Boxes.PerformAction())
      {
        // Assert the errors
        if (this.m_Boxes.Errors.Count > 0) { Assert.Fail(this.m_Boxes.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }
    #endregion
  }
}
